package com.abbas.abchat.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.abbas.abchat.R;
import com.abbas.abchat.entity.Account;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;

public class PeopleDetailActivity extends BaseActivity {

    private ImageButton ibBack;
    private TextView title;
    private ImageView img;
    private TextView nick;
    private TextView account;
    private TextView tag;
    private RelativeLayout friendRound;
    private RelativeLayout sendMsg;

    private Account ac;
    private String dbName;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_people_detail;
    }

    @Override
    protected void init() {

        ac = (Account) getIntent().getSerializableExtra("account");
        dbName = getIntent().getStringExtra("dbName");

        if (ac == null) showMessage("数据错误");
        if (!TextUtils.isEmpty(dbName)) showMessage("数据错误");

        ibBack = (ImageButton) findViewById(R.id.ib_back);
        title = (TextView) findViewById(R.id.title);
        img = (ImageView) findViewById(R.id.img);
        nick = (TextView) findViewById(R.id.nick);
        account = (TextView) findViewById(R.id.account);
        tag = (TextView) findViewById(R.id.tag);
        friendRound = (RelativeLayout) findViewById(R.id.friend_round);
        sendMsg = (RelativeLayout) findViewById(R.id.send_msg);

        Glide.with(this)
                .load(ac.getImgPath())
                .transform(new RoundedCorners(18))
                .into(img);

        nick.setText(String.format("%s", ac.getName()));
        account.setText(ac.getAccount());

    }

    @Override
    protected void initEvent() {
        ibBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finishThis();
            }
        });

        friendRound.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        sendMsg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(PeopleDetailActivity.this, ChatActivity.class);
                intent.putExtra("account",ac);
                intent.putExtra("dbName",dbName);
                startActivity(intent);

                finishThis();
            }
        });
    }


}